package com.dameng.jianyouquan.base.mvpBase;

import android.os.Bundle;
import android.widget.Toast;

import androidx.annotation.Nullable;

import com.dameng.jianyouquan.base.BaseActivity;

public abstract class BaseMvpActivity <T extends BasePresenter> extends BaseActivity implements  BaseView{

    private T mPresenter;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mPresenter= createPresenter();
        mPresenter.attachView(this);
        initData();
    }

    protected abstract void initData();

    protected abstract T createPresenter();

    @Override
    public void showToast(String msg) {
        Toast.makeText(getApplicationContext(),msg,Toast.LENGTH_SHORT).show();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mPresenter!=null){
            mPresenter.detachView();
        }
    }
}
